/*
******************************************************************************************
**
**  Copyright (C) 2011, Fujian WITSI Micro-electronic Tech. CO.,LTD., All Rights Reserved.
**
******************************************************************************************
*/
/*
******************************************************************************************
**
**	File: apitrans.h
**
**	Brief:
**
**	Logs:
**		2012.12.26		Created by ttlc
**
******************************************************************************************
*/
#ifndef ___APITRANS_H___
#define ___APITRANS_H___

/*
******************************************************************************************
**	include files 
******************************************************************************************
*/
#include <string.h>

#ifdef __cplusplus
extern "C"{
#endif
/*
******************************************************************************************
**	global referenced macro defines & type defines
******************************************************************************************
*/
#define ASYNC_STAR   1000
typedef enum {
	ERR_NONE = 0,
	ERR_PARAM,
	ERR_COMM,
	ERR_MEM,
	
	ERR_TIMEOUT,
	ERR_INTR,

	ERR_UNSUPPORT,

	//PRINTER 
	ERR_PRN_INIT,
	ERR_PRN_EXIT,
	ERR_PRN_FLUSH,
	ERR_PRN_NOTREADY,

		//ICC
	
	ERR_MAX


	
	
}ERR_CODE;
 

/*
** 
*/
typedef enum {
	t_void = 'v',
	t_int = 'd',
	t_unsigned_int = 'u',
	t_char = 'c',
	t_charp = 's'
}param_type_t;

typedef enum {
	CMD_MIN_NUM = 0x80,
	CMD_GET_FW_VER = CMD_MIN_NUM,

	// printer api
	CMD_PRN_INIT,
	CMD_PRN_EXIT,
	CMD_PRN_FLUSH,
	CMD_PRN_HEATTIME,
	CMD_PRN_GETSTATUS,
	
	// iccard api
	CMD_ICC_PRESENT,
	CMD_ICC_PWRUP,
	CMD_ICC_PWRDOWN,
	CMD_ICC_APDU,

	//LED api
	CMD_LED_CTL,
	 //BUZZER api
	 CMD_BUZZER_CTL,
	 //MAGC api
	 CMD_MAGC_START,
	 CMD_MAGC_READ,
	// =total api num
	CMD_ALL,
	CMD_MAX_NUM = 0xFF
}api_cmd_t;

#define GET_CMD_INDEX(cmd)	(cmd - CMD_MIN_NUM)
/*
** RETURN:
**	>0: package length, package in the cmd buffer
**	=0: ok and nothing to respone
**	<0: error code while excusive cmd
typedef int fn_cmd_api_t(unsigned char *cmd, int len);
*/

typedef void (*apitrans_t)(void);
#define __apitrans_entry	__attribute__((__used__, section(".apitrans")))
#define apitrans_initcall(fn)    \
        static const apitrans_t _apitrans_initcall_##fn \
        __attribute__((__used__, section(".apitrans"))) = fn

/*
******************************************************************************************
**	global referenced variables
******************************************************************************************
*/

/*
******************************************************************************************
**	global function prototype
******************************************************************************************
*/
/*
**	RETURN:
**		if success return cmd_num, return -1 for regiester failed!
*/
int cmd_api_register(api_cmd_t pid, fn_cmd_api_t *pcmd_func);

/*
**========================================================================================
**	End of this file.
**	Don't insert any data after this block.
**========================================================================================
*/
#ifdef __cplusplus
}
#endif

#endif	//___APITRANS_H___

